<?php
/**
 * Created by PhpStorm.
 * User: Panjing
 * Date: 2021/1/3
 * Time: 10:55
 */
namespace app\sign;

use fast\Http;
use think\Config;
use think\Log;

class Plocn
{
    /*
     * 归属地
     */
    public static function plocntest($tel)
    {

        $url='http://plocn.market.alicloudapi.com/plocn?n='.$tel;
        $appcode='0a3037b708154f38ad099813aa838da8';
        $headers = array();
        array_push($headers, 'Content-type:application/json;charset="utf-8"');

        array_push($headers, "Authorization:APPCODE " . $appcode);
        $options = array(
            'http' => array(
                'method' => 'GET',
                'header' => $headers,
            )
        );

        $context = stream_context_create($options);
        $result = file_get_contents($url, false, $context);

        $content = stream_context_create($options);
        $result = null;
        Log::info($content);
        $result = file((string)$url, 1, $content);
        Log::info($result);
        $output = $result[0];
        $resultjson=json_decode($output);
        Log::info($resultjson);
        if($resultjson->code==1){
            if ( strstr($resultjson->city, '吉安')){
                return 1;
            }else{
                return 0;
            }
        }else{
            return 0;
        }
    }


    /*
    * 充值
    */
    public static function teltest($tel)
    {
//        //http://114.55.205.222:80/apply/hf?sign=******&re_url=http://127.0.0.1:20000/recharge/callback&recharge_no=11111111111&user_order_no=hfTest0000000000001&uid=test&amount=50
//        $url=' http://114.55.205.222:80/apply/hf?sign=';
//
//
//        /api/demo/test4
//        $appcode='0a3037b708154f38ad099813aa838da8';
//        $headers = array();
//        array_push($headers, 'Content-type:application/json;charset="utf-8"');
//
//        array_push($headers, "Authorization:APPCODE " . $appcode);
//        $options = array(
//            'http' => array(
//                'method' => 'GET',
//                'header' => $headers,
//            )
//        );
//
//        $context = stream_context_create($options);
//        $result = file_get_contents($url, false, $context);
//
//        $content = stream_context_create($options);
//        $result = null;
//        Log::info($content);
//        $result = file((string)$url, 1, $content);
//        Log::info($result);
//        $output = $result[0];
//        $resultjson=json_decode($output);
//        Log::info($resultjson);
//        if($resultjson->code==1){
//            if ( strstr($resultjson->city, '吉安')){
//                return 1;
//            }else{
//                return 0;
//            }
//        }else{
//            return 0;
//        }
   }

}